<link type="text/css" rel="stylesheet" href="css/alliance_f.css" />
<link rel="stylesheet" type="text/css" href="css/distri.css"/>

<script type="text/javascript" src="js/jquery.getareas.js"></script>
<div class="r_content">
<h3 class="mc_title">
    <span class="mctit_1"><span class="mctit_2">配置利润比</span></span>
</h3>
<form action="call/jh_alliance.php" method="post" target="ifr" id="step1">
<div class="degcon">
    <input type="hidden" name="uid" value="<?=$a_info['id']?>" />
    <input type="hidden" name="action" value="modify"/>
    <p><b>联盟名称：</b><span><input type="text" class="inptxt wid270"  name="alliName" value="<?=$a_info['dtitle']?>" /></span></p>
    <p><b>利润比例：</b>
    <span>
    <i>平台</i><input type="text" class="profit inptxt wid50" name="profit_a" value="<?=$dratio[0]?>" /><i>%</i>
    <i>供应商</i><input type="text" class="profit inptxt wid50" name="profit_b" value="<?=$dratio[1]?>" /><i>%</i>
    <i>联盟</i><input type="text" class="profit inptxt wid50" name="profit_x" value="<?=$a_info['ratio_b']?>" /><i>%</i>
    <i>邀请人</i><input type="text" class="profit inptxt wid50" name="profit_y" value="<?=$a_info['ratio_c']?>" /><i>%</i>
    </span>
    </p>
	<p><b>联盟分配：</b>
    <span>
    <i>盟主</i><input type="text" class="profit inptxt wid50" name="profit_c" value="<?=$dratio[2]?>" /><i>%</i>
    <i>省代理</i><input type="text" class="profit inptxt wid50" name="profit_d" value="<?=$dratio[3]?>" /><i>%</i>
    <i>市代理</i><input type="text" class="profit inptxt wid50" name="profit_e" value="<?=$dratio[4]?>" /><i>%</i>
    </span>
    </p>
	<p><b>邀请人分配：</b>
    <span>
    <i>上级邀请人</i><input type="text" class="profit inptxt wid50" name="profit_f" value="<?=$dratio[5]?>" /><i>%</i>
    <i>邀请人</i><input type="text" class="profit inptxt wid50" name="profit_g" value="<?=$dratio[6]?>" /><i>%</i>
    </span>
    </p>
    <p><input type="submit" class="l_save_f" value="保存" /></p>
</div>
</form>
<iframe name="ifr" style="display:none;"></iframe>
<script type="text/javascript">
$(document).ready(function(){

    
});

function closeBg() { 
    $("#fullbg,#dialog,#dialog1").hide(); 
} 

</script>
<iframe name="ifr" style="display:none;"></iframe>
<script type="text/javascript">
$(document).ready(function(){
    
    $(".province").change(function(){
		var _this = $(this),flag = false,_html = '';	

        $.getJSON('call/jh_alliance.php',{action:'getProvince',keys:$(this).val()},function(data){
            _ds = data.key;
            _html = '<li class="itemLi odd selected" data="'+_ds+'"><ul class="topUl">';
            _html +='<ul class="topUl">';
            _html +='<li class="tcol_1 tcol">'+data.title+'</li>';
            _html +='<li class="tcol_2 tcol">';
            _html +='</li>';
            _html +='</ul>';
            _html +='<div class="botW clearfix">';
            _html +='<table class="table">';
            _html +='<thead>'
            _html +='<tr>';
            _html +='<th class="tbcol tbcol_1">地点</th>';
            _html +='<th class="tbcol tbcol_2">代理商账号</th>';
            _html +='</tr>';
            _html +='</thead>';
            _html +='<tbody>';
            
            for(var i in data.city){
                _html +='<tr>';
                _html +='<input type="hidden" name="city_code[]" value="'+data.city[i].code+'"/>';
                _html +='<td class="tname tbcol_1">'+data.city[i].ctitle+'</td>';
                _html +='<td data="'+_ds+'" class="agent_se" agent="'+data.city[i].inviter+'">';
                _html +=$("#hideSetion").html();
                _html +='</td>';
                _html +='</tr>';
            }
            _html +='</tbody>';
            _html +='</table>';
            _html +='</div>';
            _html +='</li>';
			_html +='<li><input type="submit" class="d_save" value="保存"></li>';
             $(".list-city").html(_html);
             $(".list-agent").hide();

            $(".agent_se").each(function(idx,element){
                if($(this).attr("data")==_ds && $(this).attr("agent")){
                    $(this).find(".agents").val(Number($(this).attr("agent")));
                }
            });
        });
    });
});;
</script>
<div style="display:none;" id="hideSetion">
<?=$select1;?>
</div>
<form action="call/jh_alliance.php" method="post" target="ifr">
<input type="hidden" name="action" value="setAgent"/>
<h3 class="mc_title">
    <span class="mctit_1"><span class="mctit_2">指定代理商</span></span>
</h3>
<div class="ui-c-box">
    <p class="ui-line">
        <span class="ui-title">添加代理商配置：</span>        
        <span >
            <select class="ui-select province">
                <option>请选择代理省份</option>
                <?foreach($province as $row):?>
                <option value="<?=$row['n_code']?>"><?=$row['province']?></option>
                <?endforeach;?>
            </select>
        </span>
		</br>
		<span class="ui-title">已配置的代理商：</span>
    </p>
    <style type="text/css">
    .ui-t-list{border:1px solid #ccc;margin:10px 0;width:725px;}
    .ui-t-list tr:hover{background:#F7F7D1;}
    .ui-t-list .head,.ui-t-list .head:hover{font-weight:normal;color:#000;background:#e5e5e5;}
    .ui-t-list td.w1,td.w2{width:10%;white-space:nowrap;word-break:keep-all;font-weight:bold;}
    .ui-t-list td.w2{color:#FFF;background:#254E75;}
    .ui-t-list td{padding:5px 10px;vertical-align:top;vertical-align:middle;font-size:14px;text-align: center;}
    .ui-t-list a{color:#519CEA;}
    .ui-t-list a:hover{text-decoration:underline;}
    </style>
    <?if(count($exiagent)):?>
    <div class="list-agent">
    <table class="ui-t-list" cellspacing="0" cellpadding="0" border="0">
    <tbody>
        <tr class="head"><td >代理市</td><td>代理商</td><td>指定时间</td><td>操作</td></tr>
        <?foreach($exiagent as $at):?>
        <tr><td class="w1"><?=$at['darea_title']?></td><td><?=$at['dname']?></td><td><?=$at['dtime']?></td><td><a href="#">删除</a></td></tr>
        <?endforeach;?>
    </tbody>
    </table>
    </div>
    <?endif;?>
    <div class="listWrap">
		<ul class="list-city" style="height:600px;">
		</ul>
    </div>
</div>




</form>

<h3 class="mc_title">
    <a href="distributor_add.html" target="_blank" class="ui-t-add">添加分销商</a>
    <span class="mctit_1"><span class="mctit_2">联盟成员管理</span></span>
</h3>

<form method="post" action="call/jh_alliance.php" target="ifr" class="members">
<input type="hidden" value="join" name="action" class="mAct"/>
<table class="dismtab_a">
    <thead>
        <tr>
			<th></th>
            <th>企业名称（账号）</th>
            <th>联系人</th>
            <th>手机号码</th>
			<th>状态</th>
        </tr>
    </thead>
    <tbody>
        <?foreach($disList as $k=>$dt):?>
        <tr>
			<td><input type="checkbox" name="memberID[<?=$dt['id']?>]" <?=$checked?> value="<?=$dt['id']?>" class="tids" /></td>
            <td style="text-align:left;padding-left:10px;"><a target="_blank" href="http://www.12301.cc/userinfo.html?id=<?=$dt['id']?>"><?=$dt['dname']?>（ID:<?=$dt['account']?>）</a></td>
            <td class="txtlf"><?=$dt['cname']?></td>
            <td><?=$dt['mobile']?></td>
            <td>
                <? 
                echo ($dt['dstatus']==0 && $dt['dstatus']!='') ? 
                '<span style="color:green;">已配置</span>':'<span style="color:red;">未配置</span>';
                ?>
			</td>
        </tr>
        <?endforeach;?>
    </tbody>
</table>
<div class="chose">
	 <a href="javascript:void(0);" class="ckall">全选</a> 
	 <a href="javascript:void(0);" class="reck">反选</a> 
</div>
<input type="submit" class="s_save" value="加入联盟">
<a href="javascript:void(0);" onclick="join_off()">剔除</a>
</div>
</form>
<script>
$(document).ready(function(){
    $(".dprice_tpl").change(function(){
        var se = $(this).val();
        $(".keTms").each(function(i,e){
            if($(e).val()==se) se = $(e).attr("data");
        });
        $(this).parent().siblings().find(".dprice_t").val($(this).val());
        $(this).parent().siblings().find(".dprice_z").val(se);
        $(this).parent().siblings().find(".dprice_a").html(se);
    });
    $(".s_save").click(function(){
        $(".mAct").val("join");
    });
    
    // 配置例如比例
    $("form#step1").submit(function(){
        var sum = 0;
        $(".profit").each(function(i,element){
            sum += Number($(element).val());
        });
        if(sum==100) return true;
        alert("利润比例必须等于100");
        return false;
    });
    
});
function join_off(){
    if(confirm('确定要退出联盟？')){
        $(".mAct").val("outMember");
        $(".members").submit();
    }
}
function join(){
    if(confirm('确定要加入联盟？')){
        $.getJSON("call/###.php", { dtype:dtype, id:id}, function(json){
            if(json['status']!='ok'){alert(json['msg']);}
            else{alert('加入成功!');window.location.reload();}
        });
    }
}
$(document).ready(function(){
    $(".ckall").click(function(){ // 全选
        $(".tids").attr("checked",true).parent();
    });
    $(".reck").click(function(){// 反选
        $(".tids").each(function(index,element){
            $(this).attr("checked",!this.checked).parent();
        });
    });
 });
</script>

<div id="dialog">
<p class="close"><a href="javascript:closeBg();">关闭</a>
<div>
<div class="member_login_a">
    <div class="mark_del">
    <img class="tell_img" src="../images/tell.png">
    <div class="del_t">
        <h3>抱歉!您所删除的折扣模板已有3个用户配置</h3>
        <h3>请转移这些用户至新模板</h3>
    </div>
    <div class="configure"></div>
    </div>
</div>
</div>
</div>

<div id="dialog1">
    <p class="close"><a href="javascript:closeBg();">关闭</a>
    <div class="ui-content">
    </div>
</div>